package tlog

var (
	defaultLoggers       = []LoggerWriter{NewLoggerWriter()}
	defaultLabel         = "logx"
	defaultMode          = DEV
	defaultLogWriteLimit = 5
)

type (
	Options func(opt *Option)

	Option struct {
		// 系统的开发模式
		Mode LogMod
		// 日志标签
		Label string

		LogWriteLimit int
		// 日志的Logger对象
		LoggerWriter []LoggerWriter
	}
)

func newOptions(opts ...Options) *Option {
	o := Option{
		Mode:          defaultMode,
		Label:         defaultLabel,
		LogWriteLimit: defaultLogWriteLimit,
		LoggerWriter:  defaultLoggers,
	}
	for _, opt := range opts {
		opt(&o)
	}

	return &o
}

func WithMode(mod LogMod) Options {
	return func(opt *Option) {
		opt.Mode = mod
	}
}

func WithLabel(label string) Options {
	return func(opt *Option) {
		opt.Label = label
	}
}

func WithLogWriteLimit(limit int) Options {
	return func(opt *Option) {
		opt.LogWriteLimit = limit
	}
}

func WithLoggerWriter(writers ...LoggerWriter) Options {
	return func(opt *Option) {
		opt.LoggerWriter = append(opt.LoggerWriter, writers...)
	}
}
